package test.generic;

import java.util.ArrayList;
import java.util.List;

/**
 * 可变参数与泛型方法能够很好的共存
 */
public class GenericVarargs {
    public static <T> List<T> makeList(T... args){
        List<T> result = new ArrayList<>();
        for (T arg : args) {
            result.add(arg);
        }
        return result ;
    }

    public static void main(String[] args) {
        List ls = makeList("InterfaceA");
        System.out.println(ls);
        ls = makeList("InterfaceA","B","C");
        System.out.println(ls);
        ls = makeList("ABCDEFGHIJK".split(""));
        System.out.println(ls);
    }
}
